/**
 * 
 */
package util.methods;

import java.util.AbstractList;

/**
 * Static utility methods for arrays, including command line options.
 */
public class ArrayHelpers
{
	// Removes all adjacent duplicates in the input list
	public static void removeDuplicates ( AbstractList<?> list )
	{
		if ( list.size() < 2 )
			return;
		
		int i = list.size() - 1;
		Object last = list.get( i );
		--i;
		
		for ( ; i >= 0; --i )
		{
			Object cur = list.get( i );		
			if ( cur.equals(last) )
				list.remove( i );
			last = cur;
		}
	}
	
	public static boolean contains ( int[] array, int value )
	{
		for (int i = 0;  i < array.length;  i++)
			if (array[i] == value)
				return true;
		
		return false;
	}
	
    private ArrayHelpers () { }; // Don't instantiate
}
